using Single.Core.Service;
using Single.Sugar.Service;
using Single.Sys.Entity;
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using System.Text;
using Single.Logger;
using SqlSugar;

namespace Single.Sys.Service
{
    public class SysReleaseService : BaseService<SysRelease>
    {
        public List<SysRelease> GetPageList(int pageNum, int pageSize, string version, string scale, string content, out int total)
        {
            var query = db.Queryable<SysRelease>();

            query = query.WhereIF(!string.IsNullOrEmpty(version), m => m.Version.Contains(version))
                .WhereIF(!string.IsNullOrEmpty(scale), m => m.Scale == scale)
                .WhereIF(!string.IsNullOrEmpty(content), m => m.Title.Contains(content) || m.New.Contains(content) || m.Fix.Contains(content) || m.Improved.Contains(content) || m.Other.Contains(content));

            return query.OrderByDescending(m => m.Date).OrderByDescending(m => m.CreateTime).ToPageList(pageNum, pageSize, out total);
        }
    }
}